﻿using MediatR;
using SheepStorage.API.Application.Command.SheepRecordCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepRecordHandlers
{
    public class UpdateNewBuildingCommandHandler : IRequestHandler<UpdateNewBuildingCommand, Results<int>>
    {
        ISheepRecordService _res;

        public UpdateNewBuildingCommandHandler(ISheepRecordService res)
        {
            _res = res;
        }

        public async Task<Results<int>> Handle(UpdateNewBuildingCommand request, CancellationToken cancellationToken)
        {
            var list =await _res.UpdateNewBuilding(request.OverBitTolist, request.BuildingId, request.SheepFieldId);
            return Results<int>.DataResult(list);
        }
    }
}
